package com.shengsiyuan.observer;

import java.util.Observable;

public class ConcreteObservable extends Observable {
	private String name;
	private int age;

	public ConcreteObservable(String name, int age) {
		super();
		this.name = name;
		this.age = age;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the age
	 */
	public int getAge() {
		return age;
	}

	/**
	 * @param age
	 *            the age to set
	 */
	public void setAge(int age) {
		this.age = age;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.util.Observable#notifyObservers()
	 */
	@Override
	public void notifyObservers() {
		// TODO Auto-generated method stub
		super.notifyObservers();
		System.out.println("notify you all");
	}

	public void changeName(String name) {
		if (!this.name.equals(name)) {
			this.setChanged();
			this.notifyObservers("name has been changed");
		}
	}
	public void changeAge(int age){
		if(age != this.age){
			this.setChanged();
			this.notifyObservers("age has been chaged");
		}
	}

}
